﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace SmartMD.DataModel.Entity
{
    public class FollowupInfo : BusinessEntity
    {
        private string _patientId;
        private string _patientName;
        public string ClinicNo;
        public string HospitalNo;
      //  private string _diagnose;
    
        private bool _isFirstFollowUp; //是否首次随访
        private DateTime _followupDate;
        private int _followupTimes;
        private string _followUper; //随访人
        private string _treatment;  //治疗情况
        private string _briefHistory; // 简要病史
        private string _other;  //其他问题
        private string _bloodPressure; //血压（mmHg）
        private int _breath;  //呼吸（bmp）
        private int _heatrate; //心率（bmp）
        private int _temperature; //体温（℃）
        private string _pathologyDiagnose; //病理诊断
        private string _pathologyClassification; //病理分类
        private string _pathologyLevel; //病理分级
        private string _pathologyPeriod; //病理分期
        private List<DiagnoseGroup> _diagnoseList = new List<DiagnoseGroup>();

        private ObservableCollection<string> _diagnoses = new ObservableCollection<string>(); //new ObservableCollection<string> { "Cat", "Dog", "Bear", "Lion", "Mouse", "Horse", "Rat", "Elephant", "Kangaroo", "Lizard", "Snake", "Frog", "Fish", "Butterfly", "Human", "Cow", "Bumble Bee" };

        public ObservableCollection<string> Diagnoses
        {
            get
            {
                return _diagnoses;
            }
        }
        private ObservableCollection<string> _selectedDiagnoseList; //疾病诊断列表
        public ObservableCollection<string> SelectedDiagnoseList
        {
            get
            {
                if (_selectedDiagnoseList == null)
                {
                    _selectedDiagnoseList = new ObservableCollection<string> ();
                    SelectedDiagnosesText = WriteSelectedDiagnosesString(_selectedDiagnoseList);
                    _selectedDiagnoseList.CollectionChanged +=
                        (s, e) =>
                        {
                            SelectedDiagnosesText = WriteSelectedDiagnosesString(_selectedDiagnoseList);
                            OnPropertyChanged("SelectedDiagnoseList");
                        };
                }
                return _selectedDiagnoseList;
            }
            set
            {
                _selectedDiagnoseList = value;
            }
        }
        public string SelectedDiagnosesText
        {
            get { return _selectedAnimalsText; }
            set
            {
                _selectedAnimalsText = value;
                OnPropertyChanged("SelectedDiagnosesText");
            }
        } string _selectedAnimalsText;

        private static string WriteSelectedDiagnosesString(IList<string> list)
        {
            if (list.Count == 0)
                return String.Empty;

            StringBuilder builder = new StringBuilder(list[0]);

            for (int i = 1; i < list.Count; i++)
            {
                builder.Append(", ");
                builder.Append(list[i]);
            }

            return builder.ToString();
        }

        public override void setValue(string key, Object value)
        { 
             if (value is System.DBNull)
                return;
             switch (key.ToLower())
             {
                 case "id":
                     this.Id = value.ToString();
                     break;
                 case "patientid":
                     this.PatientId = value.ToString();
                     break;
                 case "isfirstfollowup":
                     this.IsFirstFollowUp = bool.Parse( value.ToString());                  
                     break;
                 case "followupdate":
                     this.FollowupDate = DateTime.Parse(value.ToString());
                     break;
                 case "followuptimes":
                     this.FollowupTimes = int.Parse(value.ToString());
                     break;
                 case "followuper":
                     this.FollowUper = (string)value;
                     break;
                 case "treatment":
                     this.Treatment = (string)value;
                     break;
                 case "briefhistory":
                     this.BriefHistory = (string)value;
                     break;
                 case "other":
                     this.Other = (string)value;
                     break;
           
                 case "bloodpressure":
                     this.BloodPressure = value.ToString();
                     break;
                 case "breath":
                     this.Breath = int.Parse(value.ToString());
                     break;
                 case "heatrate":
                     this.Heatrate = int.Parse(value.ToString());
                     break;
                 case "temperature":
                     this.Temperature = int.Parse(value.ToString());
                     break;
                 case "pathologydiagnose":
                     this.PathologyDiagnose = value.ToString();
                     break;
                 case "pathologyclassification":
                     this.PathologyClassification = value.ToString();
                     break;
                 case "pathologylevel":
                     this.PathologyLevel = value.ToString();
                     break;
                 case "pathologyperiod":
                     this.PathologyPeriod = value.ToString();
                     break;
                 default:
                     break;
             }
        }


        public string PathologyDiagnose
        {
            get
            {
                return _pathologyDiagnose;
            }
            set
            {
                _pathologyDiagnose = value;
                OnPropertyChanged(() => PathologyDiagnose);
            }
        }
        public string PathologyClassification
        {
            get
            {
                return _pathologyClassification;
            }
            set
            {
                _pathologyClassification = value;
                OnPropertyChanged(() => PathologyClassification);
            }
        }
        public string PathologyLevel
        {
            get
            {
                return _pathologyLevel;
            }
            set
            {
                _pathologyLevel = value;
                OnPropertyChanged(() => PathologyLevel);
            }
        }
        public string PathologyPeriod
        {
            get
            {
                return _pathologyPeriod;
            }
            set
            {
                _pathologyPeriod = value;
                OnPropertyChanged(() => PathologyPeriod);
            }
        }    
        
        public bool IsFirstFollowUp
        {
            get
            {
                return _isFirstFollowUp;
            }
            set
            {
                _isFirstFollowUp = value;
                OnPropertyChanged(() => IsFirstFollowUp);
            }
        }
        public string PatientName
        {
            get
            {
                return _patientName;
            }
            set
            {
                _patientName = value;
                OnPropertyChanged(() => PatientName);
            }
        }

        public string PatientId
        {
            get
            {
                return _patientId;
            }
            set
            {
                _patientId = value;
                OnPropertyChanged(() => PatientId);
            }
        }

        public int Temperature
        {
            get
            {
                return _temperature;
            }
            set
            {
                _temperature = value;
                OnPropertyChanged(() => Temperature);
            }
        }

        public int Heatrate
        {
            get
            {
                return _heatrate;
            }
            set
            {
                _heatrate = value;
                OnPropertyChanged(() => Heatrate);
            }
        }

        public int Breath
        {
            get
            {
                return _breath;
            }
            set
            {
                _breath = value;
                OnPropertyChanged(() => Breath);
            }
        }

        public string BloodPressure
        {
            get
            {
                return _bloodPressure;
            }
            set
            {
                _bloodPressure = value;
                OnPropertyChanged(() => BloodPressure);
            }
        }

        public string Treatment
        {
            get
            {
                return _treatment;
            }
            set
            {
                _treatment = value;
                OnPropertyChanged(() => Treatment);
            }
        }

        public string BriefHistory
        {
            get
            {
                return _briefHistory;
            }
            set
            {
                _briefHistory = value;
                OnPropertyChanged(() => BriefHistory);
            }
        }
        public string Other
        {
            get
            {
                return _other;
            }
            set
            {
                _other = value;
                OnPropertyChanged(() => Other);
            }
        }

        public DateTime FollowupDate
        {
            get
            {
                return _followupDate;
            }
            set
            {
                _followupDate = value;
                OnPropertyChanged(() => FollowupDate);
            }
        }

        public int FollowupTimes
        {
            get
            {
                return _followupTimes;
            }
            set
            {
                _followupTimes = value;
                OnPropertyChanged(() => FollowupTimes);
            }
        }
        public string FollowUper
        {
            get
            {
                return _followUper;
            }
            set
            {
                _followUper = value;
                OnPropertyChanged(() => FollowUper);
            }
        }
        public List<DiagnoseGroup> DiagnoseList
        {
            get
            {
                return _diagnoseList;
            }
            set
            {
                _diagnoseList = value;
                OnPropertyChanged(() => DiagnoseList);
            }
        }
    }
}
